<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../bootstrap/bootstrap.min.css">
    <script src="../jquery/jquery-1.8.3.js"></script>
</head>
<style type="text/css">
    .div_ads {
        width: 75%;
        margin: 50px auto 0 0;
    }

    table {
        margin: 0 auto;
        width:100%;
        border-collapse:separate;
        border-spacing:0px 10px;
    }
    table tr td {
        text-align: center;
        width:150px;
        height:44px;
    }
</style>
<script>
    $(function () {
        //获取会话对象中的键值对
        var stuNum = sessionStorage.getItem('stuNum');
        var stuName = sessionStorage.getItem('stuName');
        var stuClass = sessionStorage.getItem('stuClass');

        //使用ajax请求servlet---数据库
        $.ajax({
            url:"/StuTea/ServletupStudent",
            dataType:"json",
            contentType: "Application/json",
            data:{
                "stuNum":stuNum,
                "stuName":stuName,
                "stuClass":stuClass
            },
            success:function (data) {
                //解析返回数据,填充到HTML中,不需要使用EL或JSTL
                if(data != null && data !=""){
                    $("#num").val(data.stuNum);
                    $("#name").val(data.stuName);
                    $("#sex").val(data.stuSex);
                    $("#age").val(data.stuAge);
                    $("#class").val(data.stuClass);
                    $("#major").val(data.major);
                    $("#department").val(data.department);

                }
            }
        })

        //
        // var span = $("span").val();
        // if(span!=null){
        //     span.val("修改成了")
        // }




    })
</script>

<!-- action我只写ServletEditTeacherInfo。浏览器端报404路径/StuTea/teacher/ServletEditTeacherInfo,所以浏览器默认是从webapp里开始找起的。java文件下的写绝对路径。-->
<body>
<form action="/StuTea/ServletEditStuInfo" method="post">
    <div class="div_ads">
        <span></span>
        <table>
            <tr>
                <td>学&nbsp;&nbsp;&nbsp;号：</td>
                <td><input type="text" id="num" name="stuNum" class="form-control" value="" readonly="readonly" /></td>
            </tr>
            <tr>
                <td>姓&nbsp;&nbsp;&nbsp;名：</td>
                <td><input type="text" id="name" name="stuName" class="form-control" value="" readonly="readonly"/></td>
            </tr>
            <tr>
                <td>性&nbsp;&nbsp;&nbsp;别：</td>
                <td><input type="text"  id="sex"  name="stuSex" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>年&nbsp;&nbsp;&nbsp;龄：</td>
                <td><input type="text"  id="age"  name="stuAge" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>班&nbsp;&nbsp;&nbsp;级：</td>
                <td><input type="text"  id="class" name="stuClass" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>专&nbsp;&nbsp;&nbsp;业：</td>
                <td><input type="text"  id="major" name="major" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>学&nbsp;&nbsp;&nbsp;院：</td>
                <td><input type="text"  id="department" name="department" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td><input type="submit" value="修改" class="btn btn-primary" /></td>
                <td><input type="reset"  value="清空" class="btn btn-danger" /></td>
<!--                <span id="span" value="12">afafaf</span>-->
            </tr>
        </table>
    </div>
</form>
</body>
</html>